package com.dht.xiao.jianye.base.mqtt.bean;

/**
 * @author :      fangbingran
 * @aescription : todo(这里用一句话描述这个类的作用)
 * @date :        2019/06/13  21:57
 */
public class DlcMqttConnectOptions {
    /**
     * 服务地址
     */
    private String serverUri = "";
    /**
     * 用户名称
     */
    private String userName = "";
    /**
     * 用户密码
     */
    private String passWord = "";
    /**
     * 用户id
     */
    private String clientId = "";
    /**
     * 多长时间为超时,秒
     */
    private int timeOutSeconds = 10;
    /**
     * 保存连接多长时间,秒
     */
    private int keepAliveIntervalSeconds = 30;

    /**
     * 是否清空用户信息
     */
    private boolean cleanSession = false;
    /**
     * 断开后是否自动连接
     */
    private boolean autoReconnect = true;
    /**
     * 用户id+CurrentTimeMillis()
     */
    private String clientIdCurrentTimeMillis = "";
    /**
     * 自动连接间隔时间,秒
     */
    private int autoReconnectTimeSeconds = 15;
    /**
     * 是否清空客户端
     */
    private boolean cleanClient = false;

    public DlcMqttConnectOptions(String serverUri, String userName, String passWord, String clientId) {
        this.serverUri = serverUri;
        this.userName = userName;
        this.passWord = passWord;
        this.clientId = clientId;
        this.clientIdCurrentTimeMillis = clientId + "_" + System.currentTimeMillis();
    }

    public String getServerUri() {
        return serverUri;
    }

    public void setServerUri(String serverUri) {
        this.serverUri = serverUri;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public void setClientIdCurrentTimeMillis(String clientId) {
        this.clientId = clientId;
        this.clientIdCurrentTimeMillis = clientId + "_" + System.currentTimeMillis();
    }

    public void refreshClientIdCurrentTimeMillis() {
        this.clientIdCurrentTimeMillis = this.clientId + "_" + System.currentTimeMillis();
    }

    public String getClientIdCurrentTimeMillis() {
        return clientIdCurrentTimeMillis;
    }

    public int getTimeOutSeconds() {
        return timeOutSeconds;
    }

    public void setTimeOutSeconds(int timeOutSeconds) {
        this.timeOutSeconds = timeOutSeconds;
    }

    public int getKeepAliveIntervalSeconds() {
        return keepAliveIntervalSeconds;
    }

    public void setKeepAliveIntervalSeconds(int keepAliveIntervalSeconds) {
        this.keepAliveIntervalSeconds = keepAliveIntervalSeconds;
    }


    public boolean isCleanSession() {
        return cleanSession;
    }

    public void setCleanSession(boolean cleanSession) {
        this.cleanSession = cleanSession;
    }

    public boolean isAutoReconnect() {
        return autoReconnect;
    }

    public void setAutoReconnect(boolean autoReconnect) {
        this.autoReconnect = autoReconnect;
    }

    @Override
    public String toString() {
        return "DlcMqttConnectOptions{" +
                ", 服务地址='" + serverUri + '\'' +
                ", 用户名称='" + userName + '\'' +
                ", 用户密码='" + passWord + '\'' +
                ", 用户id='" + clientId + '\'' +
                ", 多长时间为超时(秒)=" + timeOutSeconds +
                ", 保存连接多长时间(秒)=" + keepAliveIntervalSeconds +
                ", 是否清空用户信息=" + cleanSession +
                ", 断开后是否自动连接=" + autoReconnect +
                ", 自动连接间隔时间(秒)=" + autoReconnectTimeSeconds +
                '}';
    }


    public int getAutoReconnectTimeSeconds() {
        return autoReconnectTimeSeconds;
    }

    public void setAutoReconnectTimeSeconds(int autoReconnectTimeSeconds) {
        this.autoReconnectTimeSeconds = autoReconnectTimeSeconds;
    }

    public boolean isCleanClient() {
        return cleanClient;
    }

    public void setCleanClient(boolean cleanClient) {
        this.cleanClient = cleanClient;
    }
}
